import 'package:flame/components.dart';
import 'package:flutter_flappy_bird/bird.dart';

class TitleComponent extends SpriteComponent {
  TitleComponent(this.screenSize, this.birdComponent)
      : super(size: Vector2(178, 48));

  Vector2 screenSize;
  final BirdComponent birdComponent;

  @override
  Future<void>? onLoad() async {
    sprite = await Sprite.load('title.png');
  }

  @override
  void onGameResize(Vector2 size) {
    super.onGameResize(size);
    screenSize = size;
    position = Vector2((size.x - 178) / 2, (size.y / 2 - 48) / 2);
  }

  @override
  void update(double dt) {
    super.update(dt);
    if (birdComponent.getCurrentStatus() == BirdComponent.statusFlying) {
      removeFromParent();
    }
  }
}
